<?php
/*http://www.bathome.net/thread-1766-1-1.html 参考 winclip */
//exec("winclip -p d:/TMPTMP_ytempnr.htm");
//$fn=fopen("d:/TMPTMP_ytempnr.htm","r");
//$nr=fread($fn,filesize("d:/TMPTMP_ytempnr.htm"));
//fclose($fn);
@exec("winclip -p",$Info);
$nr=join("\n",$Info);

function addsla($yy)
{
    $restr = str_replace("\\", "\\\\\\", $yy);
    $restr = str_replace(".*", "allall", $yy);
    $restr = str_replace(".", "\.", $restr);
    $restr = preg_replace("/\\\$/Uisx", "\\\\\\\\\\\\$", $restr);
    $restr = preg_replace("/\"/Uisx", "\\\"", $restr);
    $restr = preg_replace("/\-/Uisx", "\\-", $restr);
    $restr = preg_replace("/\:/Uisx", "\\:", $restr);
    $restr = preg_replace("/\?/Uisx", "\\?", $restr);
    $restr = preg_replace("/\//Uisx", "\\/", $restr);
    $restr = preg_replace("/\{/Uisx", "\\{", $restr);
    $restr = preg_replace("/\}/Uisx", "\\}", $restr);
    $restr = preg_replace("/\(/Uisx", "\\(", $restr);
    $restr = preg_replace("/\)/Uisx", "\\)", $restr);
    $restr = preg_replace("/\|/Uisx", "\\|", $restr);
    $restr = preg_replace("/\,/Uisx", "\\,", $restr);
    $restr = preg_replace("/\!/Uisx", "\\!", $restr);
    $restr = preg_replace("/\^/Uisx", "\\^", $restr);
    $restr = preg_replace("/\*/Uisx", ".*", $restr);
    $restr = preg_replace("/\#/Uisx", "\\#", $restr);
    $restr = preg_replace("/\]/Uisx", "\\]", $restr);
    $restr = preg_replace("/\[/Uisx", "\\[", $restr);
    $restr = preg_replace("/\+/Uisx", "\\+", $restr);
    $restr = preg_replace("/((\\s\+)?(\\n)?\\s)+/m", "\\\s+", $restr);
    $restr = preg_replace("/MMM$/Uisx", "", $restr);
    $restr = preg_replace("/\\\\s\+MMM\\\\s\+/", "[\s\\n]+", $restr);
    $restr = str_replace("allall", ".*", $restr);
    return $restr;
}


for($i=2;$i<count($argv);$i++){
	$argv[1].=" ".$argv[$i];
}
$isA=0;
if(preg_match("/\[(.*)\]/Uisx",$argv[1],$nn)){
    $argv[1]=$nn[1];
    $isA=1;
}
if(function_exists($argv[1])&&!$isA){
    $return=$argv[1]($nr);
}elseif(!preg_match("/\;/",$argv[1])){
    $return=file_get_contents("http://xx.gxjubao.org/key.php?key=".urlencode($argv[1]));
}else{
    $return=eval($argv[1]);
}

$e=mb_detect_encoding($pagehtml,"UTF-8, ISO-8859-1, GBK");
if($e!="UTF-8") {
    $return=mb_convert_encoding($return, "utf-8", "GB2312, GBK");
}
echo $return;
$fn=fopen("d:/TMPTMP_ytempnr.htm","w");
fwrite($fn,$return." ");
fclose($fn);
@system("chcp 65001");
system("type d:\\TMPTMP_ytempnr.htm|clip");

//exec("winclip -c");
//$nr=join("\n",$Info);
//dt